#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

struct Edge {
	int to, nxt;
} e[410];
int e_cnt = 0, n, fa[210], ans, ans_pos = 0;
int tmp_l = 0, tmp_pos, cur_break;
int heads[210];
inline void add(int pre, int to) {
	e[e_cnt].to = to;
	e[e_cnt].nxt = heads[pre];
	heads[pre] = e_cnt++;
}
void dfs(int x, int l) {
	if (tmp_l < l) {
		tmp_l = l, tmp_pos = x;
	}
	for (int i = heads[x]; ~i; i = e[i].nxt) {
		int v = e[i].to;
		if (v != fa[x] && i != cur_break && i != (cur_break ^ 1)) {
			fa[v] = x;
			dfs(v, l + 1);
		}
	}
}
int main() {
	freopen("terrorize.in", "r", stdin);
	freopen("terrorize.out", "w", stdout);
	memset(heads, -1, sizeof(heads));
	scanf("%d", &n);
	int tmp1, tmp2;
	for (int i = 1; i < n; ++i) {
		scanf("%d%d", &tmp1, &tmp2);
		add(tmp1, tmp2);
		add(tmp2, tmp1);
	}
	for (cur_break = 0; cur_break < ((n - 1) << 1); cur_break += 2) {
		int s1 = e[cur_break].to;
		int s2 = e[cur_break ^ 1].to;

		tmp_l = 0;
		tmp_pos = s1;
		memset(fa, 0, sizeof(fa));
		dfs(s1, 0);

		tmp_l = 0;
		memset(fa, 0, sizeof(fa));
		dfs(tmp_pos, 0);

		int ll = tmp_l;
		tmp_l = 0;
		memset(fa, 0, sizeof(fa));
		tmp_pos = s2;
		dfs(s2, 0);

		memset(fa, 0, sizeof(fa));
		tmp_l = 0;
		dfs(tmp_pos, 0);

		ans = max(ans, ll * tmp_l);
	}
	printf("%d", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}